<?php
/**
 * @package		Joomla.Site
 * @subpackage	mod_menu
 * @copyright	Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// No direct access.
defined('_JEXEC') or die;

// Note. It is important to remove spaces between elements.
?>
				<div id="catesp" class="bg2">
					<h4><?php echo $module->title ?></h4>
<div class="accor menu<?php echo $class_sfx;?>"<?php
	$tag = '';
	if ($params->get('tag_id')!=NULL) {
		$tag = $params->get('tag_id').'';
		echo ' id="'.$tag.'"';
	}
?>>
<?php

$level = 0;
$index = -1;
$active = 0;
foreach ($list as $i => &$item) :
	$class = 'item-'.$item->id;
	if ($item->id == $active_id) {
		$class .= ' current';
	}

	if (	$item->type == 'alias' &&
			in_array($item->params->get('aliasoptions'),$path)
		||	in_array($item->id, $path)) {
		$class .= ' active';
	}

	if ($item->deeper) {
		$class .= ' deeper';
	}

	if ($item->parent) {
		$class .= ' parent';
	}

	if (!empty($class)) {
		$class = ' class="'.trim($class) .'"';
	}

	if ($level == 0) { echo '<h3'.$class.'>'; $index++; } else { echo '</h3><li'.$class.'>';}
	
	if ($item->id == $active_id) {
		$active = $index;
	}

	// Render the menu item.
	switch ($item->type) :
		case 'separator':
		case 'url':
		case 'component':
			require JModuleHelper::getLayoutPath('mod_menu', 'default_'.$item->type);
			break;

		default:
			require JModuleHelper::getLayoutPath('mod_menu', 'default_url');
			break;
	endswitch;
	
	if ($item->parent) {
		$level++;
	}
	if ($item->shallower) {	
		$level--;
	}	
	
	
		
	// The next item is deeper.
	if ($item->deeper) {
		echo '</h3><ul>';
	}
	// The next item is shallower.
	elseif ($item->shallower) {
		//echo '</div>';
		echo str_repeat('</li></ul>', $item->level_diff);
		//$level--;
	}
	// The next item is on the same level.
	else {
		if ($level == 0 && !$item->parent) { echo '</h3><ul></ul>'; } elseif ($level == 0) { echo '</h3>'; } else { echo '</li>';}
	}
	
	//echo $index;
	
endforeach;
?></div>
</div>
<script type="text/javascript">
			$(function(){

				if(<?php echo $active ?>)
				{
					$(".menu").accordion( "activate" , <?php echo $active ?> )
				}
				
				$( ".menu h3 a" ).click(function() { //id của đối tượng mà khi ấn vô muốn hiện dialog
					window.location = $(this).attr('href');

				});
				
			});
</script>		